package team.gs.io;

public class BufferData {

	public BufferData() {
		a = new byte[0];
		c = 0;
	}

	public BufferData(byte abyte0[]) {
		a = abyte0;
		c = 0;
		b = abyte0.length;
	}

	public void writeByte(byte byte0) {
		a[c++] = byte0;
		a();
	}

	private void a() {
		if (c > b)
			b = c;
	}

	protected void ensureAvail(int i) {
		int j = c + i;
		if (j > a.length) {
			byte abyte0[] = new byte[j];
			System.arraycopy(a, 0, abyte0, 0, b);
			a = abyte0;
		}
	}

	public void writeBytes(byte abyte0[], int i, int j) {
		System.arraycopy(abyte0, i, a, c, j);
		c += j;
		a();
	}

	public byte readByte() {
		return a[c++];
	}

	public byte[] readBytes(int i) {
		byte abyte0[] = new byte[i];
		System.arraycopy(a, c, abyte0, 0, i);
		c += i;
		return abyte0;
	}

	public byte[] getData() {
		return a;
	}

	public int getLength() {
		return b;
	}

	public int getPosition() {
		return c;
	}

	public void setPosition(int i) {
		c = i;
	}

	public int getCapacity() {
		return a.length;
	}

	private byte a[];
	private int b;
	private int c;
}